package cn.school.fastjson;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.alibaba.fastjson.JSON;

public class Test2 {
	public static void main(String[] args) {
		HashMap<String, Object> map = new HashMap<String, Object>();
		map.put("username", "zhangsan");
		map.put("age", 24);
		map.put("sex", "男");

		// map集合
		HashMap<String, Object> temp = new HashMap<String, Object>();
		temp.put("name", "xiaohong");
		temp.put("age", "23");
		map.put("girlInfo", temp);

		// list集合
		List<String> list = new ArrayList<String>();
		list.add("爬山");
		list.add("骑车");
		list.add("旅游");
		map.put("hobby", list);

		String jsonString = JSON.toJSONString(map);
		System.out.println("JSON=" + jsonString);
	}
}